/**
 * 
 */
package com.globallogic.training.university.study;

/**
 * Class <code>Lesson</code> is a parent class of classes <code>Lecture</code> and <code>Seminar</code>
 * This class represents common features of both classes
 * @author vasiliy.kulgaviy
 *
 */
abstract class Lesson {
	protected String topic;
	
	/**
	 * Constructs a lesson with defined Topic
	 * 
	 * @param topic
	 *            the topic of the new lesson
	 */
	protected Lesson(String topic) {
		this.topic = topic;
	}

	/**
	 * Returns the topic of the lesson
	 * 
	 * @return the topic of the lesson
	 */
	public abstract String getTopic();
	
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object other) {
		if (other == null) return false;
		
		if (this == other) return true;
		
		if (!(other instanceof Lesson)) return false;
		
		Lesson otherLesson = (Lesson) other;
		
		return topic.equals(otherLesson.getTopic());
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
        final int prime = 17;
        int result = 37;
        
        result = prime * result + topic.hashCode();

		return result;
	}
}
